package homework;

import java.io.*;

public class Test10 {
    public static void main(String[] args) {
        File dir = new File(".");
        File[] subs = dir.listFiles(f -> f.getName().endsWith(".obj"));
        for (File sub : subs) {
            try (FileInputStream fis = new FileInputStream(sub);
                 ObjectInputStream ois = new ObjectInputStream(fis)) {
                Object obj = ois.readObject();
                if (obj instanceof User) {
                    User user = (User) obj;
                    System.out.println(user);
                }
            } catch (IOException | ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
}
